﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    class LatitudeToken
    {

        public static void ParseLanguage(GPSData gpsData, System.Collections.Queue q)
        {
            
            String latToken = (string)q.Dequeue();
            
            String neswToken = (string)q.Dequeue();

            
            DirectionType dir;
            int degrees;
            double minutes;

            Toolkit.ParseLatLong(out dir, out degrees, out minutes, latToken, neswToken);
            
            gpsData.SetLatitude(degrees, minutes, dir);

            switch (gpsData.MessageType)
            {
                case MessageType.GPGGA:
                    LongitudeToken.ParseLanguage(gpsData, q);
                    break;
                case MessageType.GPRMC:
                    LongitudeToken.ParseLanguage(gpsData, q);
                    break;
                case MessageType.GPGLL:
                    LongitudeToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new InvalidLanguageException("How did you get here?");
            }
            

        }
    }
}
